package rad.framework.jsf;

import java.io.IOException;

import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;

public class HtmlTableRow extends UIComponentBase {

	public static final String COMPONENT_FAMILY = "rad.framework.jsf.HtmlTableRow";

	public static final String COMPONENT_TYPE = "rad.framework.jsf.HtmlTableRow";

	@Override
	public String getFamily() {
		return COMPONENT_FAMILY;
	}

//	@Override
//	public void restoreState(FacesContext context, Object state) {
//		Object[] values = (Object[]) state;
//		super.restoreState(context, values[0]);
//		// legend = (String) values[1];
//	}
//
//	@Override
//	public Object saveState(FacesContext context) {
//		Object[] values = new Object[2];
//		values[0] = super.saveState(context);
//		// values[1] = legend;
//		return values;
//	}

	@Override
	public void encodeBegin(FacesContext context) throws IOException {
		if (!isRendered())
			return;

		super.encodeBegin(context);
		ResponseWriter response = context.getResponseWriter();
		response.startElement("tr", this);

		response.writeAttribute("id", getClientId(context), "id");
	}

	@Override
	public void encodeEnd(FacesContext context) throws IOException {
		if (!isRendered())
			return;

		ResponseWriter response = context.getResponseWriter();
		response.endElement("tr");
		response.flush();
		super.encodeEnd(context);
	}

}
